<?php
		session_start();
define('TEMPLATES', '../templates/');
define('JS','../js/');
define('CSS','../css/');
define('OBJETOS','../objetos/');
define('NEGOCIOS','../negocio/');
define('EXTENSION','.phtml');
function __autoload($class_name){
  require_once $class_name . '.php';
}
 
Class TransaccionRegimen {
	
	var $AdminObj;
	var $generador_xhtml;
	var $vars;
	
	function TransaccionRegimen($array_vars){
		$this->AdminObj=new AdminRegimen();
		$this->vars=$array_vars;
		$this->generador_xhtml=new GeneradorXHTML();
	}

	function transNewRegimen(){
		$Regimen=$this->AdminObj->getNewObject("Regimen",array(Regimen));
		$this->generador_xhtml->mostrarTpl($Regimen,array("tpl"=>"Regimen"  ,"boton"=>"Guardar Datos","accion"=>"transSetRegimen","css"=>"Regimen","js"=>"Regimen","header1"=>"Nuevo Regimen"));
	}
	
	function transSetRegimen(){
		$this->vars['id_regimen']=$this->AdminObj->getNewID("Regimen","id_Regimen");
		$this->vars['id_datosregimen']=$this->AdminObj->getNewID("datosregimen","id_datosregimen");
		$this->vars['id_temporada_datosregimen']="1";
		$this->vars['id_regimen_datosregimen']=$this->vars['id_regimen'];
		$Regimen=$this->AdminObj->getNewObject("Regimen",$this->vars);
		$this->AdminObj->setRegimen($Regimen);
		$this->AdminObj->redireccionar("TransaccionRegimen.php");
	}
	
	function transGetRegimen(){
		$Regimen=$this->AdminObj->getRegimen($this->vars['id_regimen']);
    	$array_elementos=array("tpl"=>"Regimen"  ,"boton"=>"Guardar cambios","accion"=>"transUpdateRegimen","css"=>"Regimen","js"=>"Regimen");
		$this->generador_xhtml->mostrarTpl($Regimen,$array_elementos);
	}
	
	function transUpdateRegimen(){
		$Regimen=$this->AdminObj->getNewObject("Regimen",$this->vars);
		$this->AdminObj->updateRegimen($Regimen);
		$this->AdminObj->redireccionar("TransaccionRegimen.php");	
	}
	
	function transDeleteRegimen(){
	
		$this->AdminObj->deletedatos($this->vars['id_regimen']);
		$this->AdminObj->deleteRegimen($this->AdminObj->getRegimen($this->vars['id_regimen']));
		$this->AdminObj->redireccionar("TransaccionRegimen.php");
	}
	function transGetRegimens()
	{
		$rows=$this->generador_xhtml->generarRowsTable3($this->AdminObj->getRegimens(),"radio",false,0,array(1,4,5,6),array(0));
		$this->generador_xhtml->mostrarTpl("",array("tpl"=>"Regimenstable","rows"=>$rows,"js"=>"Regimenstable.js","css"=>"Regimen"));
	}		
}

if($_GET){
	$vars_trans=array_slice($_GET,1);
//antes no olvidar poner una validador para que nadie pueda ejecutar las funciones
	call_user_func(array(new TransaccionRegimen($vars_trans),current($_GET)?current($_GET):"transGetRegimens"));
}
else if($_POST){
		$vars_trans=array_slice($_POST,1);
		call_user_func(array(new TransaccionRegimen($vars_trans),current($_POST)?current($_POST):"transGetRegimens"));
		}
	else	call_user_func(array(new TransaccionRegimen(array()),"transGetRegimens"));

?>